package com.bss.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.andy.basics.AbstractNamedEntity;

@Entity
@Table(name = "materialtype")
public class MaterialType extends AbstractNamedEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6317473483766027802L;
	private int id;
	private String name;
	private String remarks;
	private Set<Material> materials = new HashSet<Material>(0);

	private Set<MaterialSetMapping> materialSetMappings = new HashSet<MaterialSetMapping>(
			0);

	private Set<MaterialAllocation> materialAllocations = new HashSet<MaterialAllocation>(
			0);

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final int id) {
		this.id = id;
	}

	@Column(name = "name", length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "materialType")
	public Set<Material> getMaterials() {
		return this.materials;
	}

	public void setMaterials(final Set<Material> materials) {
		this.materials = materials;
	}

	public void setRemarks(final String remarks) {
		this.remarks = remarks;
	}

	@Column(name = "remarks", length = 50)
	public String getRemarks() {
		return this.remarks;
	}

	public void setMaterialSetMappings(
			final Set<MaterialSetMapping> materialSetMappings) {
		this.materialSetMappings = materialSetMappings;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "materialType")
	public Set<MaterialSetMapping> getMaterialSetMappings() {
		return this.materialSetMappings;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "materialType")
	public Set<MaterialAllocation> getMaterialAllocations() {
		return this.materialAllocations;
	}

	public void setMaterialAllocations(
			final Set<MaterialAllocation> materialallocations) {
		this.materialAllocations = materialallocations;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", length = 19)
	public Date getDate() {
		return this.date;
	}
}
